package org.supda.system.entity;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * TMessage entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "t_message", catalog = "comsys")
public class TMessage implements java.io.Serializable {

	// Fields

	private Long id;
	private String sender;
	private Short messageType;//消息类型，1：用户消息、2：系统消息、3：告警消息;
	private String content;
	private Integer retryTimes;
	private Timestamp createTime;
	private Set<TMessageSend> TMessageSends = new HashSet<TMessageSend>(0);

	// Constructors

	/** default constructor */
	public TMessage() {
	}

	/** minimal constructor */
	public TMessage(String content, Integer retryTimes, Timestamp createTime, String sender, Short messageType) {
		this.content = content;
		this.retryTimes = retryTimes;
		this.createTime = createTime;
		this.sender = sender;
		this.messageType = messageType;
	}

	/** full constructor */
	public TMessage(String content,String sender, Short messageType, Integer retryTimes, Timestamp createTime,
			Set<TMessageSend> TMessageSends) {
		this.sender = sender;
		this.messageType = messageType;
		this.content = content;
		this.retryTimes = retryTimes;
		this.createTime = createTime;
		this.TMessageSends = TMessageSends;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "content", nullable = false, length = 1024)
	public String getContent() {
		return this.content;
	}
	
	@Column(name = "sender",  length = 255)
	public String getSender() {
		return sender;
	}

	public void setSender(String sender) {
		this.sender = sender;
	}

	@Column(name = "message_type", nullable = false)
	public Short getMessageType() {
		return messageType;
	}

	public void setMessageType(Short messageType) {
		this.messageType = messageType;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Column(name = "retry_times", nullable = false)
	public Integer getRetryTimes() {
		return this.retryTimes;
	}

	public void setRetryTimes(Integer retryTimes) {
		this.retryTimes = retryTimes;
	}

	@Column(name = "create_time", nullable = false, length = 0)
	public Timestamp getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "TMessage")
	public Set<TMessageSend> getTMessageSends() {
		return this.TMessageSends;
	}

	public void setTMessageSends(Set<TMessageSend> TMessageSends) {
		this.TMessageSends = TMessageSends;
	}

}